What is wrong with this query: "SELECT * FROM table WHERE id = $_POST[ 'id' ]"?
What is wrong with this query: "SELECT * FROM table WHERE id = $_POST[ 'id' ]"?
194027-Oct-2022
Updated on 27-Oct-2022
Home / DeveloperSection / Forums / What is wrong with this query: "SELECT * FROM table WHERE id = $_POST[ 'id' ]"?
What is wrong with this query: "SELECT * FROM table WHERE id = $_POST[ 'id' ]"?
KIRTI SHARMA
03-Nov-2022The use of table keyword it displays error when we execute the query SELECT * FROM table WHERE id = $_POST[ 'id' ]'?
Siddhi Malviya
28-Oct-2022Never use user input directly in queries.
This works:
$_POST['id'] = 27;
$sql = 'SELECT * FROM table WHERE id = $_POST[ 'id' ]'; echo $sql;
l = 'SELECT * FROM table WHERE id = $_POST[ 'id' ]';
echo $sql;